<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>部门${department == null ? '添加' : '编辑'}页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <%@include file="/common/header.jsp"%>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <%@include file="/common/top.jsp"%>
    <div class="row">
        <div class="col-sm-3">
            <%@include file="/common/menu.jsp"%>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">${department == null ? '添加' : '编辑'}部门${department != null ? " ID ".concat(department.id) : ''}</h1>
                </div>
            </div>
            <div class="row col-sm-10">
                <form class="form-horizontal" action="/department?cmd=insertOrUpdate" method="post" id="editForm">
                
                    <input type="hidden"  name="id" value="${department.id}">
                    
                    
                    <div class="form-group" >
                        <label for="name" class="col-sm-2 control-label">部门名称：</label>
                        <div class="col-sm-6">
                        <input type="text" class="form-control" id="name" name="name"  value="${department.name}">
                        </div>
                    </div>
                    
                    <div class="form-group" ${!empty employees ? '' : "style='display:none;'"}>
                        <label for="name" class="col-sm-2 control-label">部门员工：</label>
                        <div class="col-sm-6" style="margin-top: 9px;">
                        <c:choose>
                            <c:when test="${!empty employees}">
                                <c:forEach items="${employees}" var="employee">
                                    <input type="checkbox" class="" id="employeeIds" checked
                                        name="employeeIds"  value="${employee.id}">${employee.name}<br/>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <span>该部门目前没有员工</span>
                            </c:otherwise>
                        </c:choose>
                        </div>
                    </div>
                    
                    <div class="form-group" >
                        <label for="name" class="col-sm-2 control-label">没部门的：</label>
                        <div class="col-sm-6" style="margin-top: 9px;">
                        <c:choose>
                            <c:when test="${!empty nullDeptEmps}">
                                <c:forEach items="${nullDeptEmps}" var="nullDeptEmp">
                                    <input type="checkbox" class="" id="employeeIds"
                                        name="employeeIds"  value="${nullDeptEmp.id}">${nullDeptEmp.name}<br/>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <span>目前没有没有部门的员工</span>
                            </c:otherwise>
                        </c:choose>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-1 col-sm-6">
                            <button id="btn_submit" type="submit" class="btn btn-default">保存</button>
                            <button type="reset" class="btn btn-default">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>